﻿dynamic class FileType
{
	public static var T_ALL:Number = 1;
	
	public static var T_TXT:Number = Math.pow(2,1);
	public static var T_PDF:Number = Math.pow(2,2);
	public static var T_LOG:Number = Math.pow(2, 3);
	public static var T_DOC:Number = Math.pow(2, 4);
	public static var T_XLS:Number = Math.pow(2, 5);
	
	
	public static var T_JPG:Number = Math.pow(2,10);
	public static var T_PNG:Number = Math.pow(2,11);
	public static var T_GIF:Number = Math.pow(2,12);
	public static var T_BMP:Number = Math.pow(2,13);
	public static var T_TIF:Number = Math.pow(2,14);
	
	public static var T_RAR:Number = Math.pow(2,15);
	public static var T_ZIP:Number = Math.pow(2,16);
	
	public static var T_SWF:Number = Math.pow(2,17);
	public static var T_FLA:Number = Math.pow(2,18);
	public static var T_FLV:Number = Math.pow(2,19);
	
	public static var T_AVI:Number = Math.pow(2,20);
	public static var T_RM:Number = Math.pow(2, 21);
	public static var T_EXE:Number = Math.pow(2,22);
	
	
	public static function getTypeArray(type:Number):Array
	{
		trace(type)
		var typear:Array = new Array();
		var types:Object = new Object();
		types[1] = "T_ALL";
		types[Math.pow(2,1)] = "T_ALL";
		types[Math.pow(2, 2)] = "T_PDF";
		types[Math.pow(2, 3)] = "T_LOG";
		types[Math.pow(2, 4)] = "T_DOC";
		types[Math.pow(2, 5)] = "T_XLS";
		types[Math.pow(2, 10)] = "T_JPG";
		types[Math.pow(2, 11)] = "T_PNG";
		types[Math.pow(2, 12)] = "T_GIF";
		types[Math.pow(2, 13)] = "T_BMP";
		types[Math.pow(2, 14)] = "T_TIF";
		types[Math.pow(2, 15)] = "T_RAR";
		types[Math.pow(2, 16)] = "T_ZIP";
		types[Math.pow(2, 17)] = "T_SWF";
		types[Math.pow(2, 18)] = "T_FLA";
		types[Math.pow(2, 19)] = "T_FLV";
		types[Math.pow(2, 20)] = "T_AVI";
		types[Math.pow(2, 21)] = "T_RM";
		types[Math.pow(2, 22)] = "T_EXE";
		
		
		for (var i:String in types)
		{
			//trace(i)
			if ((Number(i) & type) !=0 && Number(i)!=1)
			{
				var n:String = types[i].substring(2);
				var ex:String = "*."+n.toLowerCase();
				typear.push({description:n, extension:ex});
			}
		}
		if (type & 1 == 1)
		{
			typear.push({description:"All type", extension:"*.*"});
		}
		return typear;
		
		
	}
	
}